package com.deyuanyun.pic.risk.controller.vo;

import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.risk.domain.RiskAssessment;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 风险评价统计对象
 *
 * @author huanglw
 * @date 2016-7-18
 *
 * History: [修改人][时间][修改描述]
 */
public class RiskStatisticsVO {

    // 高风险管段比例
    private String highRiskProportion;
    // 最高危险管段
    private String mostDangerousPipeSegment;
    // 最高风险管段评分
    private String mostDangerousScore;
    // 已采取措施管段
    private String measurePipeSegment;
    // 评价管道信息
    private List<RiskAssessmentDto> riskAssessmentList;
    // 管段风险评价的风险等级占比
    private List<RiskGradeDto> riskGradeList;

    public RiskStatisticsVO(String highRiskProportion, String mostDangerousPipeSegment, String mostDangerousScore, String measurePipeSegment) {
        this.highRiskProportion = highRiskProportion;
        this.mostDangerousPipeSegment = mostDangerousPipeSegment;
        this.mostDangerousScore = mostDangerousScore;
        this.measurePipeSegment = measurePipeSegment;
    }

    public String getHighRiskProportion() {
        return highRiskProportion;
    }

    public void setHighRiskProportion(String highRiskProportion) {
        this.highRiskProportion = highRiskProportion;
    }

    public String getMostDangerousPipeSegment() {
        return mostDangerousPipeSegment;
    }

    public void setMostDangerousPipeSegment(String mostDangerousPipeSegment) {
        this.mostDangerousPipeSegment = mostDangerousPipeSegment;
    }

    public String getMostDangerousScore() {
        return mostDangerousScore;
    }

    public void setMostDangerousScore(String mostDangerousScore) {
        this.mostDangerousScore = mostDangerousScore;
    }

    public String getMeasurePipeSegment() {
        return measurePipeSegment;
    }

    public void setMeasurePipeSegment(String measurePipeSegment) {
        this.measurePipeSegment = measurePipeSegment;
    }

    public List<RiskAssessmentDto> getRiskAssessmentList() {
        return riskAssessmentList;
    }

    public void setRiskAssessmentList(List<RiskAssessmentDto> riskAssessmentList) {
        this.riskAssessmentList = riskAssessmentList;
    }

    public List<RiskGradeDto> getRiskGradeList() {
        return riskGradeList;
    }

    public void setRiskGradeList(List<RiskGradeDto> riskGradeList) {
        this.riskGradeList = riskGradeList;
    }

    /**
     * 转换 风险评价信息
     * @param riskAssessmentList
     */
    public void fromRiskAssessment (List<RiskAssessment> riskAssessmentList) {
        List riskList = new ArrayList();
        for (RiskAssessment riskAssessment : riskAssessmentList) {
            riskList.add(new RiskAssessmentDto(riskAssessment.getName(),
                    NumberFormat.format((riskAssessment.getRelativeRiskScore()))));
        }
        this.riskAssessmentList = riskList;
    }

    /**
     * 转换 风险等级占比
     *
     * @param mapList
     */
    public void fromRiskGrade (List<Map> mapList) {
        List riskList = new ArrayList();
        for (Map map : mapList) {
            RiskGradeDto riskGradeDto = new RiskGradeDto((String) map.get("gradeName".toUpperCase()), map.get("countNum".toUpperCase()));
            riskList.add(riskGradeDto);
        }
        this.riskGradeList = riskList;
    }

    class RiskAssessmentDto {

        // 评价管段名称
        private String evaluateName;
        // 评价分数
        private String evaluateScore;

        private RiskAssessmentDto(String evaluateName, String evaluateScore) {
            this.evaluateName = evaluateName;
            this.evaluateScore = evaluateScore;
        }

        public String getEvaluateName() {
            return evaluateName;
        }

        public void setEvaluateName(String evaluateName) {
            this.evaluateName = evaluateName;
        }

        public String getEvaluateScore() {
            return evaluateScore;
        }

        public void setEvaluateScore(String evaluateScore) {
            this.evaluateScore = evaluateScore;
        }
    }

    class RiskGradeDto {

        // 风险等级名称
        private String gradeName;
        // 统计数量
        private Object countNum;

        private RiskGradeDto(String gradeName, Object countNum) {
            this.gradeName = gradeName;
            this.countNum = countNum;
        }

        public String getGradeName() {
            return gradeName;
        }

        public void setGradeName(String gradeName) {
            this.gradeName = gradeName;
        }

        public Object getCountNum() {
            return countNum;
        }

        public void setCountNum(Object countNum) {
            this.countNum = countNum;
        }
    }
}

